package com.xzm.springboot04web.controller;

import com.sun.javafx.collections.MappingChange;
import com.xzm.springboot04web.exception.UsernotException;
import org.codehaus.groovy.runtime.powerassert.SourceText;
import org.hibernate.validator.constraints.Email;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author 3052
 * @create 2020-08-06 20:43
 */
@Controller
public class HelloController {

/*    @RequestMapping({"/","index.html"})
    public String index() {
        return "login";
    }*/

    @ResponseBody
    @RequestMapping("/hello")
    public String hello(String user){
        System.out.println(user);
        if("root".equals(user)){
            throw new UsernotException();
        }
        return "hello";
    }

    @RequestMapping("/success")
    public String success(Map<String,Object> map){
        // 跳转界面 classpath:/templates/success.html
        map.put("name","xzm");
        return "success";
    }
}
